﻿/*******************************************************************************

    Units of Measure for C# applications

    Copyright (C) 2013 Marek Aniola

    This program is provided to you under the terms of the license
    as published at http://unitsofmeasure.codeplex.com/license


********************************************************************************/
using System;

namespace Man.UnitsOfMeasure
{
	public class SIUnitsFloat : UnitSystem<float>
	{
		#region Properties (units)

		// Length
		public UnitOfMeasure<float> Meter { get; private set; }
		public UnitOfMeasure<float> Centimeter { get; private set; }
		public UnitOfMeasure<float> Kilometer { get; private set; }
		public UnitOfMeasure<float> Inch { get; private set; }
		public UnitOfMeasure<float> Foot { get; private set; }
		public UnitOfMeasure<float> Yard { get; private set; }
		public UnitOfMeasure<float> Mile { get; private set; }

		// Time
		public UnitOfMeasure<float> Second { get; private set; }
		public UnitOfMeasure<float> Minute { get; private set; }
		public UnitOfMeasure<float> Hour { get; private set; }

		// Mass
		public UnitOfMeasure<float> Kilogram { get; private set; }
		public UnitOfMeasure<float> Gram { get; private set; }
		public UnitOfMeasure<float> Tonne { get; private set; }
		public UnitOfMeasure<float> Pound { get; private set; }

		// Temperature
		public UnitOfMeasure<float> Kelvin { get; private set; }
		public UnitOfMeasure<float> Celsius { get; private set; }
		public UnitOfMeasure<float> Rankine { get; private set; }
		public UnitOfMeasure<float> Fahrenheit { get; private set; }

		// Electric current
		public UnitOfMeasure<float> Ampere { get; private set; }
		// TODO: derived units

		// Amount of Substance
		public UnitOfMeasure<float> Mole { get; private set; }
		// TODO: derived units

		// Luminous Intensity
		public UnitOfMeasure<float> Candela { get; private set; }

		// Money
		public UnitOfMeasure<float> Euro { get; private set; }
		public UnitOfMeasure<float> Dollar { get; private set; }
		public UnitOfMeasure<float> PLN { get; private set; }

		// Area
		public UnitOfMeasure<float> SquareMeter { get; private set; }

		// Volume
		public UnitOfMeasure<float> CubicMeter { get; private set; }

		// Velocity
		public UnitOfMeasure<float> MeterPerSec { get; private set; }
		public UnitOfMeasure<float> KilometerPerHour { get; private set; }
		public UnitOfMeasure<float> MilePerHour { get; private set; }

		// Acceleration
		public UnitOfMeasure<float> MeterPerSec2 { get; private set; }

		// Force
		public UnitOfMeasure<float> Newton { get; private set; }
		public UnitOfMeasure<float> Dyne { get; private set; }

		// Pressure
		public UnitOfMeasure<float> Pascal { get; private set; }
		public UnitOfMeasure<float> Bar { get; private set; }
		public UnitOfMeasure<float> AtmTechnical { get; private set; }
		public UnitOfMeasure<float> AtmStandard { get; private set; }

		// Energy
		public UnitOfMeasure<float> Joule { get; private set; }
		public UnitOfMeasure<float> Calorie { get; private set; }
		public UnitOfMeasure<float> Erg { get; private set; }

		// Power
		public UnitOfMeasure<float> Watt { get; private set; }

		// Dimensionless
		public UnitOfMeasure<float> Radian { get; private set; }
		public UnitOfMeasure<float> Degree { get; private set; }

		#endregion

		#region Constructor(s)

		public SIUnitsFloat() :
			this(64, StringComparison.OrdinalIgnoreCase)
		{
		}

		public SIUnitsFloat(int capacity, StringComparison lookup) :
			base(capacity, lookup)
		{
			// Length ///////////////////////////////////////////////////////////////
			Meter = Unit(Magnitude.Length, "m", "meter");
			Centimeter = Unit(100.0F * Meter, "cm", "centimeter");
			Kilometer = Unit(Meter / 1000.0F, "km", "kilometer");

			Inch = Unit(Centimeter / 2.54F, "in", "inch");
			Foot = Unit(Inch / 12.0F, "ft", "feet");
			Yard = Unit(Foot / 3.0F, "yd", "yard");
			Mile = Unit(Yard / 1760.0F, "mil");

			// Time /////////////////////////////////////////////////////////////////
			Second = Unit(Magnitude.Time, "s", "second");
			Minute = Unit(Second / 60.0F, "min");
			Hour = Unit(Minute / 60.0F, "h");

			// Mass /////////////////////////////////////////////////////////////////
			Kilogram = Unit(Magnitude.Mass, "kg", "kilogram");
			Gram = Unit(1000.0F * Kilogram, "g", "gram");
			Tonne = Unit(Kilogram / 1000.0F, "t", "tonne");
			Pound = Unit(Kilogram / 0.45359237F, "lb", "pound");

			// Temperature //////////////////////////////////////////////////////////
			Kelvin = Unit(Magnitude.Temperature, "K", "kelvin");
			Celsius = Unit(Kelvin - 273.15F, "°C", "deg.C");
			Rankine = Unit((float)(9.0 / 5.0) * Kelvin, "°R", "deg.R");
			Fahrenheit = Unit((float)(9.0 / 5.0) * Celsius + 32.0F, "°F", "deg.F");

			// Electric Current /////////////////////////////////////////////////////
			Ampere = Unit(Magnitude.ElectricCurrent, "A");

			// Amount of Substance //////////////////////////////////////////////////
			Mole = Unit(Magnitude.AmountOfSubstance, "mol");

			// Luminosity ///////////////////////////////////////////////////////////
			Candela = Unit(Magnitude.Luminosity, "cd");

			// Money (rates on 2013-04-11) //////////////////////////////////////////
			Euro = Unit(Magnitude.Money, "\u20AC", "EUR");
			Dollar = Unit((float)(4.0991 / 3.1368) * Euro, "$", "USD");
			PLN = Unit(4.0991F * Euro, "zł", "PLN");

			// Area /////////////////////////////////////////////////////////////////
			SquareMeter = Unit(Meter * Meter, "m2");

			// Volume ///////////////////////////////////////////////////////////////
			CubicMeter = Unit(SquareMeter * Meter, "m3");

			// Velocity /////////////////////////////////////////////////////////////
			MeterPerSec = Unit(Meter / Second, "m/s");
			KilometerPerHour = Unit(Kilometer / Hour, "km/h");
			MilePerHour = Unit(Mile / Hour, "mph", "mi/h");

			// Acceleration /////////////////////////////////////////////////////////
			MeterPerSec2 = Unit(MeterPerSec / Second, "m/s2");

			// Force ////////////////////////////////////////////////////////////////
			Newton = Unit(Kilogram * MeterPerSec2, "N");
			Dyne = Unit(1.0e5F * Newton, "dyn");

			// Pressure /////////////////////////////////////////////////////////////
			Pascal = Unit(Newton / SquareMeter, "Pa");
			Bar = Unit(Pascal / 1.0e5F, "bar");
			AtmTechnical = Unit(Pascal / 9.80665e4F, "at");
			AtmStandard = Unit(Pascal / 1.01325e5F, "atm");

			// Energy ///////////////////////////////////////////////////////////////
			Joule = Unit(Newton * Meter, "J");
			Calorie = Unit(Joule / 4.1868F, "cal");
			Erg = Unit(1.0e7F * Joule, "erg");

			// Power ////////////////////////////////////////////////////////////////
			Watt = Unit(Joule / Second, "W");

			// Dimensionless ////////////////////////////////////////////////////////
			Radian = Unit(Meter / Meter, "rad");
			Degree = Unit((float)(180.0 / Math.PI) * Radian, String.Empty, new string[] { "°" });

		}
		#endregion Constructor
	}
}
